package com.shengdong.water.code.adapter

import com.shengdong.water.R
import com.shengdong.water.code.base.BaseRecyclerAdapter
import com.shengdong.water.code.bean.Outlet
import com.shengdong.water.databinding.ItemOutletBinding

class OutletAdapter : BaseRecyclerAdapter<Outlet, ItemOutletBinding>() {
    override fun getLayoutId() = R.layout.item_outlet

    override fun bindData(binding: ItemOutletBinding, item: Outlet, position: Int) {
        binding.item = item

        // 可以在这里添加额外的绑定逻辑
        binding.itemName.text = item.name

        binding.executePendingBindings()
    }

    // 如果User有唯一ID，可以重写这个方法提高效率
    override fun areItemsTheSame(oldItem: Outlet, newItem: Outlet): Boolean {
        return oldItem.id == newItem.id
    }

    // 内容比较可以更精确
    override fun areContentsTheSame(oldItem: Outlet, newItem: Outlet): Boolean {
        return oldItem.id == newItem.id && oldItem.name == newItem.name
    }
}